﻿/// <reference path="../classes.js" />
/// <reference path="qunit-1.11.0.js" />

// Methos for testing:
//  - initialize
//  - renderPartial
//  - renderFull

(function () {
    module("Initialize");
    test("Empty initialization", function () {
        // new Machine(years, guarantee, amortizationPeriod)
        var machine = new Machine();
        equal(machine.yearsOld, undefined, "Default yearsOld");
        equal(machine.guarantee, undefined, "Default guarantee");
        equal(machine.amortizationPeriod, undefined, "Default amortizationPeriod");
    });
    test("Normal initialization", function () {
        // new Machine(years, guarantee, amortizationPeriod)
        var years = 7,
            guarantee = 5,
            amortizationPeriod = 10;

        var machine = new Machine(years, guarantee, amortizationPeriod);
        equal(machine.yearsOld, years, "yearsOld");
        equal(machine.guarantee, guarantee, "guarantee");
        equal(machine.amortizationPeriod, amortizationPeriod, "amortizationPeriod");
    });

    module("RenderPartial");
    test("Render machine", function () {
        var years = 7,
            guarantee = 5,
            amortizationPeriod = 10;

        var machine = new Machine(years, guarantee, amortizationPeriod);
        // var machine = new Machine(7, 5, 10);
        var fixture = document.getElementById("qunit-fixture");
        var container = machine.renderPartial()[0];
        $(fixture).append(container);
        equal(container.className, "machine");
    });

    module("RenderFull");
    test("Render machine", function () {
        var years = 7,
            guarantee = 5,
            amortizationPeriod = 10;

        var machine = new Machine(years, guarantee, amortizationPeriod);
        var fixture = document.getElementById("qunit-fixture");
        var container = machine.renderFull();
        $(fixture).append(container);

        var divs = fixture.getElementsByTagName("div");
        equal(divs.length, 5);
    });
}());